package com.my.httpapi.api.baseUtils;

import com.google.gson.Gson;

import java.util.HashMap;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;

public class RequestParameter {
    public static RequestParameter generate() {
        return new RequestParameter();
    }

    private Map<String, Object> mParams = createMap();

    private Map<String, Object> createMap() {
        Map<String, Object> hashMap = new HashMap<>();
        return hashMap;
    }

    public Map<String, Object> getMap() {
        return mParams;
    }

    public RequestParameter getParams(Map<String, Object> map) {
        mParams.putAll(map);
        return this;
    }

    public RequestBody create() {
        Gson gson = new Gson();
        String pull = gson.toJson(mParams);
        return RequestBody.create(MediaType.parse("application/json; charset=utf-8"), pull);
    }
}
